From 60d3378dd146be7fe1b7c71c793fb37f5c9d093f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 10 Jan 2018 11:02:10 +0100 Subject: [PATCH] entry: Fix text clipping Clipping the text to the entire widget allocation is wrong if there are icons involved. --- gtk/gtkentry.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index fd3742d199..a66b0114ec 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3389,22 +3389,21 @@ gtk_entry_snapshot (GtkWidget *widget, { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); - graphene_rect_t bounds; int i; - graphene_rect_init (&bounds, - 0, 0, - gtk_widget_get_width (widget), - gtk_widget_get_height (widget)); - - gtk_snapshot_push_clip (snapshot, &bounds, "Entry Clip"); - /* Draw progress */ if (priv->progress_widget && gtk_widget_get_visible (priv->progress_widget)) gtk_widget_snapshot_child (widget, priv->progress_widget, snapshot); - /* Draw text and cursor */ + gtk_snapshot_push_clip (snapshot, + &GRAPHENE_RECT_INIT ( + priv->text_x, + 0, + priv->text_width, + gtk_widget_get_height (widget)), + "Entry Clip"); + /* Draw text and cursor */ if (priv->dnd_position != -1) gtk_entry_draw_cursor (GTK_ENTRY (widget), snapshot, CURSOR_DND); @@ -3416,6 +3415,8 @@ gtk_entry_snapshot (GtkWidget *widget, priv->selection_bound == priv->current_pos && priv->cursor_visible) gtk_entry_draw_cursor (GTK_ENTRY (widget), snapshot, CURSOR_STANDARD); + gtk_snapshot_pop (snapshot); + /* Draw icons */ for (i = 0; i < MAX_ICONS; i++) { @@ -3426,8 +3427,6 @@ gtk_entry_snapshot (GtkWidget *widget, } gtk_entry_draw_undershoot (entry, snapshot); - - gtk_snapshot_pop (snapshot); } static void -- 2.30.2